﻿using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Threading;

namespace 枚举序列化
{
    class Program
    {
        static void Main(string[] args)
        {
            List<A> list = new List<A>
            {
                new A(1,"001", Season.夏),
                new A(2,"002", Season.春),
                new A(3,"003", Season.冬),
                new A(4,"004", Season.秋),
                new A(5,"005", Season.夏),
                new A(6,"006", Season.春),
                new A(7,"007", Season.冬),
                new A(8,"008", Season.ChunXia),
                new A(9,"009", Season.夏),
            };

            var data = JsonConvert.SerializeObject(list);
            Console.WriteLine(data);


            Console.ReadKey();
        }
    }


    public class A
    {

        public A(int id,string name,Season season)
        {
            Id = id;
            Name = name;
            Season = season;
        }

        public int Id { get; set; }
        public string Name { get; set; }

        [JsonConverter(typeof(StringEnumConverter),true)] // true 标识序列化后 首字母为小写
       
        public Season Season { get; set; }
       
    }

    public enum Season
    { 
        春,夏,秋,冬,ChunXia
    
    }

   

}
